//
//  ASRManager.m
//  ASR_Demo
//
//  Created by marco on 16/3/9.
//  Copyright © 2016年 Marco. All rights reserved.
//

#import "ASRManager.h"
#import "ASRManager_JTHS.h"
#import "ASRManager_KDXF.h"


NSString * const g_kASRComplete_ZH = @"g_kASRComplete_ZH";

NSString * const g_kASRComplete_UYGHUR = @"g_kASRComplete_UYGHUR";

NSString * const g_kASRSampleRateRate_8kb = @"audioformat=pcm8k16bit";
NSString * const g_kASRSampleRateRate_16kb = @"audioformat=pcm16k16bit";

@implementation ASRManager

+(instancetype) sharedManager
{
    static ASRManager* instance = nil;
//    dispatch_once_t token;
//    dispatch_once(&token, ^{
//        instance = [ASRManager new];
//    });
    if( !instance )
    {
        instance = [self new];

    }
    return instance;
}

- (int) realtimeRecog:(NSData*)pData type:(ASRSystemType)pType
{
    if( ASR_TYPE == kASR_TYPE_JIEGONGHUASHENG )
    {
        return [[ASRManager_JTHS sharedManager] realtimeRecog:pData type:pType ];
    }
    else if (ASR_TYPE == kASR_TYPE_KEDAXUNFEI)
    {
        return [[ASRManager_KDXF sharedManager] realtimeRecog:pData type:pType ];
    }
    return 0;
}


- (int) openSystem:(ASRSystemType)pType samplingRate:(NSString*)pSamplingRate
{
    if( ASR_TYPE == kASR_TYPE_JIEGONGHUASHENG )
    {
        return [[ASRManager_JTHS sharedManager] openSystem:pType samplingRate:pSamplingRate ];
    }
    else if (ASR_TYPE == kASR_TYPE_KEDAXUNFEI)
    {
        return [[ASRManager_KDXF sharedManager] openSystem:pType samplingRate:pSamplingRate ];
    }
    return 0;
}
- (void)closeSystem
{
    if( ASR_TYPE == kASR_TYPE_JIEGONGHUASHENG )
    {
        [[ASRManager_JTHS sharedManager] closeSystem];
    }
    else if (ASR_TYPE == kASR_TYPE_KEDAXUNFEI)
    {
        [[ASRManager_KDXF sharedManager] closeSystem];
    }
}


@end
